<extend name="Layout:layout_dialog" />
<block name="body_main">
    <form action="{:U('dispatch_edit_save')}" method="post" class="xsui-form">
        <div style="width:600px;">
            <div style="width:300px; float:left; max-height: 200px; overflow-y: auto;">
                <div style="margin-left:5px;">共<strong style="color:#F00; font-weight:bold; padding:0px 3px;">{$sum.count}</strong>个客户<!--, 其中有订单客户<strong style="color:#F00; font-weight:bold; padding:0px 3px;">{$sum.has_order_count}</strong>个--></div>
                <table class="xsui-table xsui-table-bordered" data-checkbox-attr='name="id[]" value=":value"'>
                    <thead>
                        <tr>
                            <th>客户编号</th>
                            <th>客户姓名</th>
                            <!--<th>购买次数</th>-->
                        </tr>
                    </thead>
                    <tbody>
                    <foreach name="list" item="vo">
                        <tr data-key="{$vo.id}">
                            <td>{$vo.serial_no}</td>
                            <td>{$vo.name}</td>
                            <!--<td>{$vo.buy_count}</td>-->
                        </tr>
                    </foreach>
                    </tbody>
                </table>
            </div>
            <div style="width:280px; float:left; margin-left:10px;" class="xsui-form-vertical">
                <div class="xsui-form-field">
                    <label>分配工号：</label>
                    <div style="width:320px;">
                        <select id="exten-picker" data-url="{:U('UserSeat/get_users_json')}"><option value="">工号</option><option value="201">201</option></select>
                        <input type="text" name="new_users" placeholder="请从左侧下拉框选择工号" size="28" readonly="readonly" />
                        <button type="button" id="btn-clear">清空</button>
                    </div>
                </div>
                <div class="xsui-form-field">
                    <label>人均分配：</label>
                    <input type="text" name="per_num" placeholder="不填则由系统后台分配,如：10" size="42" />
                </div>
                <div class="xsui-form-field">
                    <label>备注信息：</label>
                    <input type="text" name="remark" placeholder="备注信息" size="42" />
                </div>
                <button type="submit" class="ui-state-default"><i class="fa fa-save"></i>保存</button>
                <button type="reset" class="ui-state-default">重置</button>
            </div>
            <div style="clear:both;"></div>
        </div>
    </form>
</block>
<block name="body_after">
    <script type="text/javascript">
        /**
         * 数组操作
         * @param {type} arr
         * @param {type} val
         * @returns {Boolean}
         * @since 1.0 2016-7-22 SoChishun Added.
         */
        function array_indexOf(arr, val) {
            for (var i in arr) {
                if (val == arr[i]) {
                    return true;
                }
            }
            return false;
        }
        $(function () {
            $(':checkbox').prop('checked', true); // 默认全部勾选
        })
        $('#btn-clear').click(function () {
            $('[name="new_users"]').val('');
            return false;
        })
        // 2016-7-22
        ajax_combobox({selector: '#exten-picker', def_option: '工号'}); // 动态加载工号
        $('#exten-picker').change(function () {
            var val = $(this).val();
            if (!val) {
                return;
            }
            var svals = $('[name="new_users"]').val();
            var avals;
            if (svals) {
                var avals = svals.split(',');
                if (array_indexOf(avals, val)) {
                    return;
                }
                avals.push(val);
            } else {
                avals = [val];
            }
            $('[name="new_users"]').val(avals.join());
        })
        $('.notbreakline-ellipsis').hover(function () {
            $(this).attr('title', $(this).text());
        })
        var $frmSearch = $('#frmSearch');
        $frmSearch.find(':button').click(function () {
            $frmSearch.find('select option[value=""]').prop('selected', true);
            $frmSearch.find(':text').val('');
        })
    </script>
</block>